import React from 'react'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'

const Home = React.lazy(() => import('../pages/Home'))
const FenLei = React.lazy(() => import('../pages/FenLei'))
const MiQuan = React.lazy(() => import('../pages/MiQuan'))
const Car = React.lazy(() => import('../pages/Car'))
const My = React.lazy(() => import('../pages/My'))

import Tabbars from '../components/Tabbar'

const Tuijian = React.lazy(() => import('../pages/home/tuijian'))
const Shouji = React.lazy(() => import('../pages/home/Shouji'))
const Zhineng = React.lazy(() => import('../pages/home/Zhineng'))
const Dianshi = React.lazy(() => import('../pages/home/Dianshi'))
const Jiadian = React.lazy(() => import('../pages/home/Jiadian'))
const Bijiben = React.lazy(() => import('../pages/home/Bijiben'))

function AppRouter() {
    return (
        <div>
            {/* 配置一级路由 */}
            <BrowserRouter>

                {/* 底部导航栏 */}
                <Tabbars></Tabbars>

                <Routes>
                    <Route path='/home' element={<Home />}>
                        {/* 配置首页中的二级路由 */}
                        <Route index  element={<Tuijian />} />
                        <Route path='/home/shouji' element={<Shouji />} />
                        <Route path='/home/zhineng' element={<Zhineng />} />
                        <Route path='/home/dianshi' element={<Dianshi />} />
                        <Route path='/home/jiadian' element={<Jiadian />} />
                        <Route path='/home/bijiben' element={<Bijiben />} />
                    </Route>
                    <Route path='/fenlei' element={<FenLei />} />
                    <Route path='/miquan' element={<MiQuan />} />
                    <Route path='/car' element={<Car />} />
                    <Route path='/my' element={<My />} />
                    {/* 重定向 */}
                    <Route path='/' element={<Navigate to={'/home'} />} />
                </Routes>
            </BrowserRouter>
        </div>
    )
}

export default AppRouter
